<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ECSHOP 管理中心 - 添加分类 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="__PUBLIC__/admin/css/general.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/css/main.css" rel="stylesheet" type="text/css" />

<link href="__PUBLIC__/css/layui.css" rel="stylesheet" type="text/css" media="all"/>
<script type="text/javascript" src="__PUBLIC__/layui.js"></script>

</head>
<body>

<h1>
<span class="action-span"><a href="{:U('admin/cat/catelist')}">商品分类</a></span>
<span class="action-span1"><a href="#">添加分类</a> </span>
<div style="clear:both"></div>
</h1>

<div class="main-div">
  <form class="layui-form" method="post">
  <table width="100%" id="general-table">
      <tr>
        <td class="label">分类名称:</td>
        <td>
          <input type='text' name='cat_name' required  lay-verify="required" placeholder="请输入分类名称" style="height: 25px;margin-bottom: 10px;">
          <font color="red">*</font>
        </td>
      </tr>
      <tr>
        <td class="label">上级分类:</td>
        <td>
        <div style="width: 150px;margin-bottom: 10px;">
          <select name="parent_id">
            <option value="0">顶级分类</option>
            <?php foreach ($cats as $v) { ?>
            <option value="{$v.cat_id}">
              {$v.lev|str_repeat='&nbsp;',###}{$v.cat_name}
            </option>
            <?php } ?>
          </select>
        </div>
        </td>
      </tr>
      <tr>
        <td class="label">商品简介:</td>
        <td>
        <div style="width: 400px;">
          <textarea class="layui-textarea" name="intro" id="LAY_demo1"></textarea>
        </div>  
        </td>
      </tr>
      </table>
      <div class="button-div">
        <button lay-submit lay-filter="*"> 确定 </button>
        <input type="reset" value=" 重置 " />
      </div>
    <!-- <input type="hidden" name="act" value="insert" />
    <input type="hidden" name="old_cat_name" value="" />
    <input type="hidden" name="cat_id" value="" /> -->
  </form>
</div>

<div id="footer">
共执行 3 个查询，用时 0.021687 秒，Gzip 已禁用，内存占用 2.081 MB<br />
版权所有 &copy; 2005-2010 上海商派网络科技有限公司，并保留所有权利。
</div>

<script type="text/javascript">
    layui.use(['form','layedit'], function(){
      $ = layui.jquery;
      var layer = layui.layer
      ,layedit = layui.layedit
      ,form = layui.form();
      //layer.msg('Hello World');

  //创建一个编辑器
  var editIndex = layedit.build('LAY_demo1', {height: 100,
                tool: ['strong','italic','underline','del']
                });

    form.on('submit(*)', function(data){
        data.field.intro = layedit.getContent(editIndex);
        $.ajax({
            url: "{:U('admin/cat/cateadd')}",//请求地址
            type: "post",//请求方式
            dataType: "json",//返回数据类型
            data: data.field,//发送的参数
            })
            .done(function(response) {
                  if(response.error==0){
                     layer.msg(response.info ,{icon:5});

                  }else{
                     layer.msg(response.info ,{icon:6});
                     location.href = response.url;
                  }
              })
            .fail(function() {
                alert("ajxs交互失败");
            })  

          return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });  
    });
</script>
</body>
</html>